<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
	layout:decorator="v2/layout">
  <head>
    <title>欢迎进入管理系统</title>
    <script type="text/javascript" th:inline="javascript">
    	var orgName = [[${session.user.name}]];
    	var id = getParam("id");
    	
    	var beginAt = new Date().DateAdd(-14).Format("yyyy-MM-dd");
    	var endAt = new Date().Format("yyyy-MM-dd");
       	var findDate = function(beginAt, endAt){
       		var head = head = [{name:'报名收费', show:true, open:true},
              			        {name:'商品收费', show:true, open:false},
               			        {name:'投票收费', show:true, open:false}];
       		//详细数据（表格加载）
       		$.ajaxData({url:"list-detailStat", data:{id:id,beginAt:beginAt,endAt:endAt,type:'SF'}, success:function(ret){
       			var x=[];
   				var yData = [];
       			$.each(ret, function(i,v){
       				x.unshift(v.date);
       			});
       			$("#infoDetailCounts").loadData({counts:ret});
       			//echarts图形表格
       			$.each(head, function(i,v){
       				if(v.show){
   	    				var show = (i==0?true:false);
   	    				var headData = {name:v.name,show:v.open,data:[]};
   	    				$.each(ret, function(i2,v2){
   	    					var count = (v2[v.name]==null?0:v2[v.name])
   	    					headData.data.unshift(count)
   	       				});
   	    				yData.push(headData);
       				}
       			})
      			$("#echarts").echartsLine({xData:x, yData:yData});
       		}});
       		
       		$("#listPage").pageReload({beginAt:beginAt,endAt:endAt});
       	};
        
       	var export_execl = function(){
       		location.href='list-detailApplyExportExecl?id='+id+'&beginAt='+beginAt+'&endAt='+endAt;
       	}
       	
    	$(function(){
    		setMenu("收费管理");
    		
    		$.ajaxData({url:"list-detailOrderStatCount",data:{evaluateId:id},success:function(data){
    			data.bsbmSum = (data.bsbmSum==null?0:data.bsbmSum)
    			data.bsbmSumDay = (data.bsbmSumDay==null?0:data.bsbmSumDay)
    			data.spSum = (data.spSum==null?0:data.spSum)
    			data.spSumDay = (data.spSumDay==null?0:data.spSumDay)
    			data.bstpSum = (data.bstpSum==null?0:data.bstpSum)
    			data.bstpSumDay = (data.bstpSumDay==null?0:data.bstpSumDay)
    			$("#indexCount").loadData(data);
    		}})
    		
    		
    		$("#listPage").page({url:"list-detailOrderList",data:{evaluateId:id,beginAt:beginAt,endAt:endAt}, success:function(ret){
      			$.each(ret.obj.content, function(i,v){
        			v.createdAt = new Date(v.createdAt).Format("yyyy-MM-dd HH:mm:ss");
        			v.payAt = new Date(v.payAt).Format("yyyy-MM-dd HH:mm:ss");
        		});
      			$("#list").loadData({content:ret.obj.content,orgName:orgName});
      		}});
    		
    		findDate(beginAt, endAt);
    		
    		$("#day li[data-day]").click(function(){
    			var day = $(this).data("day");
    			$("#day li").removeClass("active");
    			$(this).addClass("active");
    			if(day != ''){
    				beginAt = new Date().DateAdd(-day).Format("yyyy-MM-dd");
    				endAt = new Date().Format("yyyy-MM-dd");
    			} else {
    				beginAt = null;
    				endAt = null;
    			}
    			findDate(beginAt, endAt);
    		});
    		
    		$("#listStatDate").showDate({beginAt:beginAt,endAt:endAt,success:function(ret){
    			findDate(ret.beginAt, ret.endAt);
    		}});
    		
    	});
    </script>
    <style>

    </style>
  </head>
  <body>
    <div layout:fragment="content">
    	<div class="info info-full">
    		<div class="stat">
	            <div class="stat-top">
	                <span class="stat-title"><strong>关键数据</strong></span>
	            </div>
	            <div class="stat-content">
	            	<script type="text/template" id="indexCount">
	            	<div class="stat-row" id="statCount">
		                <div class="stat-group active">
		                    <div class="stat-group-title">报名费</div>
		                    <div class="stat-group-count"><strong>#{bsbmSum}#</strong></div>
		                    <div class="stat-group-day">
		                        <label>今日</label>
		                        <span>#{bsbmSumDay}#</span>
		                    </div>
		                </div>
		                <div class="stat-group">
		                    <div class="stat-group-title">商品</div>
		                    <div class="stat-group-count"><strong>#{spSum}#</strong></div>
		                    <div class="stat-group-day">
		                        <label>今日</label>
		                        <span>#{spSumDay}#</span>
		                    </div>
		                </div>
		                <div class="stat-group">
		                    <div class="stat-group-title">投票</div>
		                    <div class="stat-group-count"><strong>#{bstpSum}#</strong></div>
		                    <div class="stat-group-day">
		                        <label>今日</label>
		                        <span>#{bstpSumDay}#</span>
		                    </div>
		                </div>
	                </div>
	                </script>
	            </div>
	
	        </div>
    	</div>
    	
    	<div class="c_tab">
   			<ul class="c_tab-list" id="day">
   				<li data-day="7">7天</li>
   				<li data-day="14" class="active">14天</li>
   				<li data-day="30">30天</li>
   				<li data-day="">全部</li>
   				<li class="c_tab-date">
   					<div id="listStatDate"></div>
   					
   				</li>
   			</ul>
    	</div>
    	
    	
		<div class="info info-full">
			<div style="height: 300px;" id="echarts"></div>
			
				<div class="detail-table">
       				<h4 class="detail-table-title">
						详细数据
					</h4>
				    <div class="table_list">
		               <div class="table-overflow">
		                   <table class="table">
		                       <thead>
			                       <tr>
	                                 <th>付款时间</th>
	                                 <th>用户</th>
	                                 <th>流水号</th>
	                                 <th>全部类型</th>
	                                 <th>付款状态</th>
	                                 <th>付款方式</th>
	                                 <th>费用</th>
			                       </tr>
		                       </thead>
		                       <tbody>
		                       <script type="text/template" id="list">
								#for(data:content)#
									<tr>
										<td>#{data.payAt}#</td>
										<td>#{data.userName}# (#{data.userNumber}#)</td>
										<td>#{data.outTradeNo}#</td>
                                        <td>#{data.typeDesc}#</td>
                                        <td>#{data.payStateDesc}#</td>
										<td>#{data.tradeType}#</td>
										<td>#{data.total}#</td>
									</tr>
								#endfor#
								</script>
		                     </tbody>
		                 </table>
		                 <div id="listPage"></div>
		             </div>
		          </div>
	          </div>
    	</div>
    	
    </div>
  </body>
</html>